package com.mind.ridge.controller;

import com.mind.ridge.pojo.front.ShoppingCart;
import com.mind.ridge.service.front.ShoppingCartService;
import com.mind.ridge.utils.R;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import java.util.List;

/**
 * @author Mind
 */
@RestController
@RequestMapping("/shoppingCart")
public class ShoppingCartController {

    @Resource
    private ShoppingCartService shoppingCartService;

    @PostMapping("/add")
    public R<String> add(@RequestBody ShoppingCart shoppingCart, HttpSession session){
        return shoppingCartService.add(shoppingCart, session);
    }

    @GetMapping("/list")
    public R<List<ShoppingCart>> list(HttpSession session){
        return shoppingCartService.cartList(session);
    }

    @PostMapping("/sub")
    public R<String> sub(@RequestBody ShoppingCart shoppingCart){
        return shoppingCartService.sub(shoppingCart);
    }
}
